﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CTC
{
    internal class CTCMsg
    {
        #region CTC命令标识枚举
        /// <summary>
        /// 应答指令
        /// </summary>
        public static readonly byte[] CTC_CMD_ACK = new byte[] { 0x00, 0x01 };
        /// <summary>
        /// 握手指令
        /// </summary>
        public static readonly byte[] CTC_CMD_HANDSHAKE = new byte[] { 0x00, 0x02 };
        /// <summary>
        /// 握手应答
        /// </summary>
        public static readonly byte[] CTC_CMD_HANDSHAKE_RSP = new byte[] { 0x00, 0x03 };
        /// <summary>
        /// 抄表指令
        /// </summary>
        public static readonly byte[] CTC_CMD_METER_READ = new byte[] { 0x00, 0x04 };
        /// <summary>
        /// 抄表数据回传
        /// </summary>
        public static readonly byte[] CTC_CMD_METER_DATA = new byte[] { 0x00, 0x05 };
        /// <summary>
        /// 心跳指令
        /// </summary>
        public static readonly byte[] CTC_CMD_HEARTBEAT = new byte[] { 0x00, 0x06 };
        /// <summary>
        /// 心跳应答
        /// </summary>
        public static readonly byte[] CTC_CMD_HEARTBEAT_RSP = new byte[] { 0x00, 0x07 };
        /// <summary>
        /// 投币指令
        /// </summary>
        public static readonly byte[] CTC_CMD_COIN_IN = new byte[] { 0x00, 0x08 };
        /// <summary>
        /// 投币应答
        /// </summary>
        public static readonly byte[] CTC_CMD_COIN_IN_RSP = new byte[] { 0x00, 0x09 };
        /// <summary>
        /// 通道选择指令
        /// </summary>
        public static readonly byte[] CTC_CMD_CHANNEL_SEL = new byte[] { 0x00, 0x0A };
        /// <summary>
        /// 奖励指令
        /// </summary>
        public static readonly byte[] CTC_CMD_REWARD = new byte[] { 0x00, 0x0B };
        /// <summary>
        /// 实体数据(实物币,实物票)上报
        /// </summary>
        public static readonly byte[] CTC_CMD_PHYSICAL_REPORT = new byte[] { 0x00, 0x0C };
        /// <summary>
        /// 查询投币数
        /// </summary>
        public static readonly byte[] CTC_CMD_QUERY_COIN = new byte[] { 0x00, 0x0D };
        /// <summary>
        /// 查询投币数应答
        /// </summary>
        public static readonly byte[] CTC_CMD_QUERY_COIN_RSP = new byte[] { 0x00, 0x0E };
        /// <summary>
        /// 设置投币数
        /// </summary>
        public static readonly byte[] CTC_CMD_SET_COIN = new byte[] { 0x00, 0x0F };
        /// <summary>
        /// 氛围控制指令
        /// </summary>
        public static readonly byte[] CTC_CMD_ATMOSPHEREEVENT = new byte[] { 0x00, 0x10 };
        #endregion

        #region CTC命令数据长度枚举
        public static readonly int CTC_CMDLEN_ACK = 3;  // 2 + 1（ACK消息长度）
        public static readonly int CTC_CMDLEN_HANDSHAKE = 22;  // 4 + 16 + 2（CTC_HandshakeMsgV1）
        public static readonly int CTC_CMDLEN_HANDSHAKE_RSP = 22;  // 4 + 16 + 2（CTC_HandshakeRspMsgV1）
        public static readonly int CTC_CMDLEN_METER_DATA_RSP = 50;  // 1 + 4（CTC_MeterDataRspMsgV1）
        public static readonly int CTC_CMDLEN_HEARTBEAT = 1;  // 1（CTC_HeartbeatMsgV1）
        public static readonly int CTC_CMDLEN_HEARTBEAT_RSP = 3;  // 1 + 2（CTC_HeartbeatRspMsgV1）
        public static readonly int CTC_CMDLEN_COIN_IN = 36;  // 4 + 16 + 16（CTC_CoinInMsgV1）
        public static readonly int CTC_CMDLEN_COIN_IN_RSP = 17;  // 1 + 16（CTC_CoinInRspMsgV1）
        public static readonly int CTC_CMDLEN_CHANNEL_SEL = 2;  // 1 + 1（CTC_ChannelSelMsgV1）
        public static readonly int CTC_CMDLEN_REWARD = 5;  // 1 + 4（CTC_RewardMsgV1）
        public static readonly int CTC_CMDLEN_PHYSICAL_REPORT = 5;  // 1 + 4（CTC_PhysicalReportMsgV1）
        public static readonly int CTC_CMDLEN_QUERY_COIN = 2;  // 2（CTC_CoinPriceMsgV1）
        public static readonly int CTC_CMDLEN_SET_COIN = 2;  // 2（CTC_CoinPriceMsgV1）
        public static readonly int CTC_CMDLEN_ATMOSPHERE_EVENT = 7; // 2 + 1 + 4（CTC_AtmosphereData）
        #endregion
        #region ACK结果码(CTC_CMD_ACK)
        /// <summary>
        /// 成功
        /// </summary>
        public const byte CTC_ACK_SUCCESS = 0x00;
        /// <summary>
        /// 包头错误
        /// </summary>
        public const byte CTC_ACK_HEADER_ERR = 0x01;
        /// <summary>
        /// CRC错误
        /// </summary>
        public const byte CTC_ACK_CRC_ERR = 0x02;
        /// <summary>
        /// 长度错误
        /// </summary>
        public const byte CTC_ACK_LENGTH_ERR = 0x03;
        /// <summary>
        /// 不支持的命令
        /// </summary>
        public const byte CTC_ACK_UNSUPPORTED = 0x04;
        /// <summary>
        /// 超时
        /// </summary>
        public const byte CTC_ACK_TIMEOUT = 0x05;
        /// <summary>
        /// 设备忙,接收方缓冲区已满
        /// </summary>
        public const byte CTC_ACK_BUSY = 100;
        #endregion
    }
}
